﻿Imports System.IO

Public Class Lab4_ask4
    Private Sub LoadImage(ByVal str As String)
        Dim fs As FileStream
        Try
            fs = New FileStream(str, FileMode.Open)
            fs.Close()

            PictureBox1.ImageLocation = str
        Catch ex As FileNotFoundException
            MessageBox.Show("FileNotFoundException for file " & str)
        Catch ex1 As OutOfMemoryException
            MessageBox.Show("OutOfMemoryException(Not An Image) for file " & str)
        Catch ex2 As Exception
            MessageBox.Show(ex2.ToString)
        Finally

        End Try
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'LoadImage(Application.ExecutablePath + "\images\db.png")
        LoadImage("C:\Users\user\Desktop\db.png")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        'LoadImage(Application.ExecutablePath + "\images\db23.png")
        LoadImage("C:\Users\user\Desktop\db232.png")
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        'LoadImage(Application.ExecutablePath + "\images\db23.txt")
        LoadImage("C:\Users\user\Desktop\db.txt")
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        'LoadImage(Application.ExecutablePath + "\images\")
        LoadImage("C:\Users\user\Desktop\")
    End Sub
End Class